from google.appengine.ext import webapp
from google.appengine.ext.webapp import template

from models import TaskModel, UserModel, GroupModel, MessageModel



class MainPage(webapp.RequestHandler):
    def get(self):
            
        
        # GQL is similar to SQL             
        tasks = TaskModel.all()
        groups = GroupModel.all()
        users = UserModel.all()
        messages = MessageModel.all()
        
        values = {
            'tasks': tasks,
            'tasks_count' : tasks.count(),
            'groups' : groups,
            'groups_count' : groups.count(),
            'users' : users,
            'users_count' : users.count(),
            'messages' : messages,
            'messages_count' : messages.count(),
        }
        self.response.out.write(template.render('index.html', values))
    
            
        

    
    

    
class Api(webapp.RequestHandler):
    def get(self):
        self.response.out.write(template.render('api.html', {}))
        
        